<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2016/9/8
  Time: 15:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <jsp:include page="../../head.jsp"/>
    <title>Title</title>
    <script type="application/javascript" src="../../js/gtimp3/declaration.js"></script>
    <script type="text/javascript">
        var formSetting = {
            title: "查询信息",
            module: 'query',
            columns: [
                {
                    name: "declaration_Type",
                    label: "进出口类型",
                    type: "dropdown",
                    data: [["进口", "I"], ["出口", "E"]],
                    op: "eq",
                    minLength: 0
                }, {
                    name: "contract_No",
                    label: "合同协议号"
                }, {
                    name: "business_Id",
                    label: "业务编号"
                }, {
                    name: "container_No",
                    label: "集装箱号"
                }, {
                    name: "company_Co",
                    label: "收发货人",
                    type: "dropdown",
                    dropdownType: "ajax",
                    url: "../order-dropdown/company",
                    op: "eq",
                    minLength: 1,
                    keyWordName: "key",
                    success: function (data) {
                        data = data.results;
                        var array = new Array();
                        $.each(data, function (i, n) {
                            array.push([n["text"], n["value"]]);
                        });
                        return array;
                    }
                }, {
                    name: "bl_no",
                    label: "提运单号"
                }, {
                    name: "confirm_Time",
                    label: "提交时间起",
                    type: "date",
                    op: "ge"
                }, {
                    name: "confirm_Time",
                    label: "提交时间止",
                    type: "date",
                    op: "le"
                }, {
                    name: "supplier.COM_NAME",
                    label: "业务供应商"
                }],
            buttons: {
                custom: []
            },
            grid: {
                id: "declarationsDataGrid",
                title: "查询结果",
                url: "../business/reject/findRejectList",
                multiselect: true,
                colModel: [{
                    index: "ID",
                    name: "declaration.id",
                    hidden: true
                }, {
                    index: "DECLARATION_TYPE",
                    name: "declaration.declarationType",
                    hidden: true
                }, {
                    index: "business_Id",
                    name: "declaration.businessId",
                    label: "业务编号",
                    formatter: function (cellvalue, options, rowObject) {
                        return "<a href=\"javascript:;\" onclick=\"javascript:doEdit('"
                            + rowObject.declaration.id + "','"
                            + rowObject.declaration.declarationType + "','"
                            + rowObject.declaration.enter_page + "');\">" + cellvalue
                            + "</a>";
                    }
                }, {
                    index: "container_No",
                    name: "declaration.containerNo",
                    label: "集装箱号"
                }, {
                    index: "contract_No",
                    name: "declaration.contractNo",
                    label: "合同协议号"
                }, {
                    index: "COMPANY_NAME",
                    name: "declaration.companyName",
                    label: "收发货人"
                }, {
                    index: "supplier.COM_NAME",
                    name: "declaration.supCompany.comName",
                    label: "业务供应商"
                }, {
                    index: "confirm_Time",
                    name: "declaration.confirmTime",
                    label: "业务提交时间"
                }, {
                    index: "creator",
                    name: "declaration.creator",
                    label: "下单人"
                }, {
                    index: "initiator.u_name",
                    name: "initiatorName",
                    label: "驳回发起人"
                }, {
                    index: "acceptor.u_name",
                    name: "acceptorName",
                    label: "驳回受理人"
                }, {
                    index: "ACCEPTED_TIME",
                    name: "acceptedTime",
                    label: "驳回受理时间"
                }, {
                    index: "REJECT_REASON",
                    name: "rejectReason",
                    label: "驳回原因",
                    formatter: function (cellvalue, options, rowObject) {
                        if (!cellvalue) {
                            cellvalue = "";
                        }
                        return "<a href=\"javascript:;\" onclick=\"javascript:showRemark('"
                            + rowObject.initRemark + "');\">"
                            + cellvalue
                            + "</a>";
                    }
                }, {
                    index: "ACCEPTED_OPINION",
                    name: "acceptedOpinion",
                    label: "受理意见"
                }, {
                    index: "INIT_REMARK",
                    name: "initRemark",
                    label: "受理意见",
                    hidden: true
                }],
                sortname: "business_Id",
                sortorder: "desc",
                ondblClickRow: function (rowid, iRow, iCol, e) {
                    if (rowid) {
                        var rowData = $("#declarationsDataGrid").jqGrid("getRowData", rowid);
                        doEdit(rowData['declaration.id'], rowData['declaration.declarationType'],rowData['declaration.enter_page']);
                    }
                }
            }
        };
        $(document).ready(function () {
            $("#declarationsDataTable").mrdForm(formSetting);
        });
        function doEdit(id, declaration_type,pageType) {
            if (!id || !declaration_type) {
                alert("打开页面错误，请与管理员联系！");
                return;
            }
            if (pageType){
                if (pageType == "CROPPED5") {
                    location.href = "<s:url value="/business/agent/order/update?id="/>" + id;
                }else{
                    location.href = "<s:url value="/order/update?id="/>" + id;
                }
            }else{
                location.href = "<s:url value="/order/update?id="/>" + id;
            }

        }
        function doDel(id) {
            $.ajax({
                url: "./deleteUnpaidDeclaration",
                type: "POST",
                data: "tdateaa=" + timeNum() + "&id=" + id,
                success: function (data) {
                    layer.close(layerIndex);
                    data = $.parseJSON(data.msg);
                    alert(data.msg);
                    if (data.state == "1") {
                        $("#declarationsDataTable").mrdForm("refreshGrid");
                    }
                }
            });
        }
        function showRemark(remark) {
            if (remark == "null" || remark == "" || remark == "undefined") {
                remark = "没有备注信息！";
            }
            jw.alert(remark);
        }
    </script>
</head>
<body>
<div id="declarationsDataTable"></div>
</body>
</html>
